/**
 * Created by asus on 2017/6/28.
 */

var common_tip_show=function(msg, position, duration) {
    if(!msg){
        var m=document.getElementById('core_show_div');
        var d = 0.2;
        m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
        m.style.opacity = '0';
        setTimeout(function() {
            document.body.removeChild(m)
        }, d * 1000);
        return;
    }
    if(position!='bottom' && position!='middle' && position!='top'){
        position ='bottom';
    }
    duration = isNaN(duration) ? 1000 : duration;
    var m = document.createElement('div');
    m.id = 'core_show_div';
    m.innerHTML = msg;
    var css = "width:60%; fonts-size:14px;min-width:150px; background:#000; opacity:0.7; min-height:35px; overflow:hidden; color:#fff; line-height:35px; text-align:center; border-radius:5px; position:fixed; left:20%; z-index:999999;box-shadow:3px 3px 4px #d9d9d9;-webkit-box-shadow: 3px 3px 4px #d9d9d9;-moz-box-shadow: 3px 3px 4px #d9d9d9;";
    if(position=='top'){
        css+="top:10%; ";
    } else if(position=='bottom'){
        css+="bottom:10%; ";
    } else if(position=='middle'){
        css+="top:50%;margin-top:-18px;";
    }
    m.style.cssText = css;
    document.body.appendChild(m);
    if(duration!=0){
        setTimeout(function() {
            var d = 0.2;
            m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
            m.style.opacity = '0';
            setTimeout(function() {
                document.body.removeChild(m)
            }, d * 1000);
        }, duration);
    }
};

